<template>
	<wsPage :title="$t('Permission.memberManagement')">
		<div slot="page_operate">
			<Button type="ghost" @click="refresh"><Icon type="refresh"></Icon><span>{{$t('Permission.refresh')}}</span></Button>
		</div>
		<wsSmPanel :page="table.page" @simple-query="query" @page-change="query">
			<div slot="query_form">
				<Form :model="queryForm" :label-width="100" inline>
					<FormItem :label="$t('Permission.username')">
			            <Input v-model="queryForm.userName" :placeholder="$t('Permission.pleaseEnter')"></Input>
			        </FormItem>
			        <FormItem :label="$t('Permission.loginname')">
			            <Input v-model="queryForm.loginName" :placeholder="$t('Permission.pleaseEnter')"></Input>
			        </FormItem>
			        <FormItem :label="$t('Permission.gender')">
			            <Select clearable v-model="queryForm.sex" :placeholder="$t('Permission.pleaseChoose')" class="ws-form-select">
			                <Option value="1">{{$t('Permission.male')}}</Option>
			                <Option value="2">{{$t('Permission.female')}}</Option>
			            </Select>
			        </FormItem>
			        <FormItem :label="$t('Permission.status')">
			            <Select clearable v-model="queryForm.status" :placeholder="$t('Permission.pleaseChoose')" class="ws-form-select">
			                <Option value="1">{{$t('Permission.normal')}}</Option>
			                <Option value="2">{{$t('Permission.locking')}}</Option>
			            </Select>
			        </FormItem>
				</Form>
			</div>
			<div slot="list_operate">
				<Button type="ghost" @click="showAddModal">{{$t('Permission.CreateUser')}}</Button>
				<Button type="ghost" :disabled="!isTableSelected" @click="batchDelAccounts" v-if="1!=1">{{$t('user.batchDeletion')}}</Button>
				<Button type="ghost" :disabled="!isTableSelected" @click="confirmResetAccountPwd">{{$t('user.resetPassword')}}</Button>
			</div>
			<div slot="list_data">
				<Table border :columns="table.columns" :data="table.data" :loading="table.loading" @on-selection-change="tableSelected"></Table>
			</div>
		</wsSmPanel>
		
		<!--新增账号弹框-->
		<wsModal v-model="accountModal.show" :ok-text="$t('Permission.save')" :cancelText="$t('Permission.cancel')"  :title="accountModal.title" @on-ok="accountModalOk" @on-cancel="accountModalCancel">
		    <Form ref="accountForm" :model="accountModal.form" :rules="accountModal.validate" :label-width="100">
		        <FormItem :label="$t('Permission.loginname')" prop="loginName">
		            <Input v-model="accountModal.form.loginName" :disabled="isEdit" autofocus></Input>
		        </FormItem>
		        <FormItem :label="$t('Permission.username')" prop="userName">
		            <Input v-model="accountModal.form.userName"></Input>
		        </FormItem>
		        <FormItem :label="$t('Permission.department')" prop="departmentId">
		            <Select v-model="accountModal.form.departmentId" :placeholder="$t('Permission.pleaseChoose')">
		                <Option :value="role.id" v-for="role in fields.roles">{{role.name}}</Option>
		            </Select>
		        </FormItem>	
		        <FormItem :label="$t('Permission.password')" prop="password" v-if="!isEdit">
		            <Input v-model="accountModal.form.password" type="password"></Input>
		        </FormItem>	
		        <FormItem :label="$t('Permission.gender')" prop="sex">
		            <Select v-model="accountModal.form.sex" :placeholder="$t('Permission.pleaseChoose')">
		                <Option value="1">{{$t('Permission.male')}}</Option>
		                <Option value="2">{{$t('Permission.female')}}</Option>
		            </Select>
		        </FormItem>	
		        <FormItem :label="$t('Permission.Remarks')">
		            <Input v-model="accountModal.form.remark" type="textarea"></Input>
		        </FormItem>	
		    </Form>			
		</wsModal>		
	</wsPage>
</template>

<script>
	import Util from '../../../common/util.js';
	import Common from '../../../common/common.js';
	export default {
		data() {
			return {
				queryForm: {
					userName: '',
					loginName: '',
					sex: '',
					status: ''
				},
				table: {
					columns: [{
                        type: 'selection',
                        width: 60,
                        align: 'center',
                        fixed: 'left'
                    },{
						title: '用户名',
                        key: 'userName',
                        width: 160,
                        fixed: 'left'
					},{
						title: '登录名',
                        key: 'loginName',
//                      width: 200
					},{
						title: '性别',
                        key: 'sex',
                        width: 100,
                        align: 'center',
                        render: (h, params) => {
                        	return h('span', {
                        		
                        	}, params.row.sex === '1' ? '男' : '女')
                        }
					},{
						title: '部门',
                        key: 'departmentName',//departmentId
//                      width: 200
					},{
						title: '创建时间',
                        key: 'createDateStr',
//                      width: 200
					},{
						title: '状态',
                        key: 'status',
                        width: 80,
                        fixed: 'right',
                        align: 'center',
                        render: (h, params) => {
                        	return h('Tag', {
                        		props: {
                        			type: 'border',
                        			color: params.row.status === '1' ? 'blue' : 'yellow'
                        		}
                        	}, params.row.status === '1' ? '正常' : '锁定')
                        }
					}, {
						title: '操作',
						width: 180,
						fixed: 'right',
						align: 'center',
						render: (h, params) => {
							return h('div', [h('Button', {
								props: {
                                    type: 'text',
                                    size: 'small'
                                },
								on: {
									click: () => {
										this.showEditModal(params.row);
									}
								}
							}, '编辑'),h('Button', {
								props: {
                                    type: 'text',
                                    size: 'small'
                                },
								on: {
									click: () => {
										let row_ = params.row;
										if(params.row.status === '1') {
											this.confirmLockAccount(row_);
										} else {
											this.confirmUnLockAccount(row_);
										}
									}
								}
							}, params.row.status === '1' ? '锁定' : '解锁'),h('Button', {
								props: {
                                    type: 'text',
                                    size: 'small'
                                },
								on: {
									click: () => {
										let row_ = params.row;
                                    	this.delConfirm(row_);
									}
								}
							}, '删除')])
						}
					}],
					data: [],
					page: {
						total: 0, //总条数
						pageNum: 1, //当前页
						pageSize: 10 //每页显示条数
					},
					selection: [], //选中
					loading: false
				},
				fields: {
					roles: []
				},
				//新增账号弹框
				accountModal: {
					show: false,
					title: '',
					form: {
						id: '',
						userName: '',
						loginName: '',
						password: '',
						sex: '',
						remark: '',
						departmentId: ''
					},
					validate: {
						userName: [
	                        { required: true, message: '用户名不能为空'}
	                    ],
	                    loginName: [
	                        { required: true, message: '登录名不能为空'},
	                        { validator: Common.validateEmail, trigger: 'blur' }
	                    ],
	                    departmentId: [
	                        { required: true, message: '请选择部门'}
	                    ],
	                    sex: [
	                        { required: true, message: '请选择性别'}
	                    ],
	                    password: [
	                        { required: true, message: '请输入密码'},
	                        { validator: Common.validateLoginPassword, message: '最少6位,包括至少大写字母、小写字母、数字、特殊字符(!@#$%^&*?)',trigger: 'blur' }
	                    ]
					}
				}
			}
		},
		computed: {
			/**
			 * 表格行是否为选中状态
			 */
			isTableSelected() {
				return this.table.selection.length > 0;
			},
			/**
			 * 当前的modal1是否为编辑状态
			 */
		    isEdit() {
		      return !Util.vad.isBlank(this.accountModal.form.id);
		    }
		},
		mounted() {
			this.init();
			// 当前选择的语言版本
			let getCurrentLanguage=localStorage.getItem('currentLanguage');
			this.$i18n.locale=getCurrentLanguage;
			if(this.$i18n.locale=='en'){
				this.table.columns=[
					{
                        type: 'selection',
                        width: 60,
                        align: 'center',
                        fixed: 'left'
                    },{
						title: 'username',
                        key: 'userName',
                        width: 160,
                        fixed: 'left'
					},{
						title: 'log-in name',
                        key: 'loginName',
//                      width: 200
					},{
						title: 'gender',
                        key: 'sex',
                        width: 100,
                        align: 'center',
                        render: (h, params) => {
                        	return h('span', {
                        		
                        	}, params.row.sex === '1' ? 'male' : 'Female')
                        }
					},{
						title: 'department',
                        key: 'departmentName',//departmentId
//                      width: 200
					},{
						title: 'Creation time',
                        key: 'createDateStr',
//                      width: 200
					},{
						title: 'status',
                        key: 'status',
                        width: 80,
                        fixed: 'right',
                        align: 'center',
                        render: (h, params) => {
                        	return h('Tag', {
                        		props: {
                        			type: 'border',
                        			color: params.row.status === '1' ? 'blue' : 'yellow'
                        		}
                        	}, params.row.status === '1' ? 'normal' : 'locking')
                        }
					}, {
						title: 'operating',
						width: 180,
						fixed: 'right',
						align: 'center',
						render: (h, params) => {
							return h('div', [h('Button', {
								props: {
                                    type: 'text',
                                    size: 'small'
                                },
								on: {
									click: () => {
										this.showEditModal(params.row);
									}
								}
							}, 'edit'),h('Button', {
								props: {
                                    type: 'text',
                                    size: 'small'
                                },
								on: {
									click: () => {
										let row_ = params.row;
										if(params.row.status === '1') {
											this.confirmLockAccount(row_);
										} else {
											this.confirmUnLockAccount(row_);
										}
									}
								}
							}, params.row.status === '1' ? 'locking' : 'Unlock'),h('Button', {
								props: {
                                    type: 'text',
                                    size: 'small'
                                },
								on: {
									click: () => {
										let row_ = params.row;
                                    	this.delConfirm(row_);
									}
								}
							}, 'delete')])
						}
					}
				];

				this.accountModal.validate={
					userName: [
	                        { required: true, message: 'Username can not be empty'}
	                    ],
	                    loginName: [
	                        { required: true, message: 'Login name cannot be empty'},
	                        { validator: Common.validateEmail, trigger: 'blur' }
	                    ],
	                    departmentId: [
	                        { required: true, message: 'Please select a department'}
	                    ],
	                    sex: [
	                        { required: true, message: 'Please select gender'}
	                    ],
	                    password: [
	                        { required: true, message: 'Please enter your password'},
	                        { validator: Common.validateLoginPassword, message: 'A minimum of 6 digits, including at least uppercase letters, lowercase letters, numbers, special characters (!@#$%^&*?)',trigger: 'blur' }
	                    ]
				}

			}else if(this.$i18n.locale=='it'){
				// 意大利版本
				this.table.columns=[
					{
                        type: 'selection',
                        width: 60,
                        align: 'center',
                        fixed: 'left'
                    },{
						title: 'nome utente',
                        key: 'userName',
                        width: 160,
                        fixed: 'left'
					},{
						title: 'Nome di accesso',
                        key: 'loginName',
//                      width: 200
					},{
						title: 'genere',
                        key: 'sex',
                        width: 100,
                        align: 'center',
                        render: (h, params) => {
                        	return h('span', {
                        		
                        	}, params.row.sex === '1' ? 'maschio' : 'donna')
                        }
					},{
						title: 'reparto',
                        key: 'departmentName',//departmentId
//                      width: 200
					},{
						title: 'Tempo di creazione',
                        key: 'createDateStr',
//                      width: 200
					},{
						title: 'stato',
                        key: 'status',
                        width: 80,
                        fixed: 'right',
                        align: 'center',
                        render: (h, params) => {
                        	return h('Tag', {
                        		props: {
                        			type: 'border',
                        			color: params.row.status === '1' ? 'blue' : 'yellow'
                        		}
                        	}, params.row.status === '1' ? 'normale' : 'Blocco')
                        }
					}, {
						title: 'operativo',
						width: 180,
						fixed: 'right',
						align: 'center',
						render: (h, params) => {
							return h('div', [h('Button', {
								props: {
                                    type: 'text',
                                    size: 'small'
                                },
								on: {
									click: () => {
										this.showEditModal(params.row);
									}
								}
							}, 'Modifica'),h('Button', {
								props: {
                                    type: 'text',
                                    size: 'small'
                                },
								on: {
									click: () => {
										let row_ = params.row;
										if(params.row.status === '1') {
											this.confirmLockAccount(row_);
										} else {
											this.confirmUnLockAccount(row_);
										}
									}
								}
							}, params.row.status === '1' ? 'Blocco' : 'sbloccare'),h('Button', {
								props: {
                                    type: 'text',
                                    size: 'small'
                                },
								on: {
									click: () => {
										let row_ = params.row;
                                    	this.delConfirm(row_);
									}
								}
							}, 'cancellato')])
						}
					}
				];

				this.accountModal.validate={
					userName: [
	                        { required: true, message: 'Il nome utente non può essere vuoto'}
	                    ],
	                    loginName: [
	                        { required: true, message: 'Il nome di accesso non può essere vuoto'},
	                        { validator: Common.validateEmail, trigger: 'blur' }
	                    ],
	                    departmentId: [
	                        { required: true, message: 'Si prega di selezionare un dipartimento'}
	                    ],
	                    sex: [
	                        { required: true, message: 'Si prega di selezionare il sesso'}
	                    ],
	                    password: [
	                        { required: true, message: 'Per favore inserisci la tua password'},
	                        { validator: Common.validateLoginPassword, message: 'Almeno 6 cifre, comprese almeno lettere maiuscole, lettere minuscole, numeri, caratteri speciali(!@#$%^&*?)',trigger: 'blur' }
	                    ]
				}

			}
		},
		methods: {
			init() {
				this.query();
			},
			/**
			 * 刷新
			 */
			refresh() {
				this.queryForm = {
					userName: '',
					loginName: '',
					sex: '',
					status: ''
				};
				this.table.page = {
					total: 0, //总条数
					pageNum: 1, //当前页
					pageSize: 10 //每页显示条数
				};
				this.init();
			},
			/**
			 * 表单查询
			 */
			query() {
				let pageSize = this.table.page.pageSize;
				let pageNum = this.table.page.pageNum;
				const _this = this;
				this.axios.get('/ws/sys/new/users/' + pageSize + '/' + pageNum, {params: this.queryForm}).then(response => {
					var res = response.data;
					var resMeta = res.meta;
					if (0 == resMeta.code) {
						_this.buildPageData(res.data);
					} else {
						_this.$Message.warning(resMeta.message);
					}
				});
			},
			/**
			 * 构建表格数据
			 */
			buildPageData(data_) {
				this.table.data = data_.list;
				this.table.page.total = data_.total;
			},
			/**
			 * 显示添加的模态框
			 */
			showAddModal() {
				this.accountModal.show = true;			
				if(this.$i18n.locale=='en'){
					this.accountModal.title = 'Create a member account';
				}else if(this.$i18n.locale=='zh') {
					this.accountModal.title = '创建成员账号';
				}else if(this.$i18n.locale=='it') {
					this.accountModal.title = 'Crea un account membro';
				}
				this.initRoles();
				this.initAdd();
			},
			/**
			 * 显示编辑弹框
			 */
			showEditModal(row_) {
				this.accountModal.show = true;			
				if(this.$i18n.locale=='en'){
					this.accountModal.title = 'Edit member account';
				}else if(this.$i18n.locale=='zh'){
					this.accountModal.title = '编辑成员账号';
				}else if(this.$i18n.locale=='it') {
					this.accountModal.title = "Modifica l'account membro";
				}
				this.initRoles();
				this.initEdit(row_);
			},			
			/**
			 * 初始化新增
			 */
			initAdd() {
				this.accountModal.form = {
					id: '',
					userName: '',
					loginName: '',
					password: '',
					sex: '',
					remark: '',
					departmentId: ''
				};
			},
			/**
			 * 编辑初始化
			 */
			initEdit(row_) {
				const _this = this;
				let cId_ = row_.id;
				let rsv_ = row_.rsv_;
				this.axios.get('/ws/sys/new/user/' + cId_ + '/' + rsv_).then(function(response) {
					let res = response.data;
					if(0 === res.meta.code) {
						_this.buildEditData(res.data);
					} else {
						let message_ = res.meta.message;

						if(_this.$i18n.locale=='zh'){
							_this.$Message.warning('初始化编辑操作失败:' + message_);
						}else if(_this.$i18n.locale=='en'){
							_this.$Message.warning('Initial edit operation failed:' + message_);
						}else if(_this.$i18n.locale=='it'){
							_this.$Message.warning('Operazione di modifica iniziale fallita:' + message_);
						}
						
					}
				});				
			},
			/**
			 * 初始化角色
			 */
			initRoles() {
				const _this = this;
				this.axios.get('/ws/sys/roles').then(response => {
					var res = response.data;
					var resMeta = res.meta;
					if (0 == resMeta.code) {
						_this.buildFiledRoles(res.data);
					} else {
						_this.$Message.warning(resMeta.message);
					}
				});				
			},
			/**
			 * 构建角色列表
			 */
			buildFiledRoles(data_) {
				this.fields.roles = data_;
			},
			/**
			 * 初始化编辑数据
			 */
			buildEditData(data_) {
				this.accountModal.form = {
					id: data_.id,
					userName: data_.userName,
					loginName: data_.loginName,
					sex: data_.sex,
					remark: data_.remark,
					departmentId: data_.departmentId
				};
			},
			/**
			 * 账号新增的弹框确认操作
			 */
			accountModalOk() {
				this.$refs['accountForm'].validate((valid) => {
					if (valid) {
                        this.submitModal1();
                    } 
                    
               });
			},
			/**
			 * 提交模态框事件
			 */
			submitModal1() {
				if(this.isEdit) {
					this.editModal1();
				} else {
					this.saveModal1();
				}
			},
			/**
			 * 提交模态框1
			 */
			saveModal1() {
				let postData_ = this.accountModal.form;
				const _this = this;
				this.axios.post('/ws/sys/new/user', postData_).then(function(response) {
					let res = response.data;
					if(0 === res.meta.code) {
						if(_this.$i18n.locale=='zh'){
							_this.$Message.success('创建成员账号成功');
						}else if(_this.$i18n.locale=='en'){
							_this.$Message.success('Create a member account successfully');
						}else if(_this.$i18n.locale=='it'){
							_this.$Message.success('Crea un account membro con successo');
						}
						
						_this.accountModalCancel();
						_this.init();
					} else {
						let message_ = res.meta.message;
						if(_this.$i18n.locale=='zh'){
							_this.$Message.warning('创建成员账号失败:' + message_);
						}else if(_this.$i18n.locale=='en'){
							_this.$Message.warning('Failed to create member account:' + message_);
						}else if(_this.$i18n.locale=='en'){
							_this.$Message.warning('Impossibile creare un account membro:' + message_);
						}
						
					}
				});
			},
			/**
			 * 编辑模态框1
			 */
			editModal1() {
				let postData_ = this.accountModal.form;
				const _this = this;
				this.axios.put('/ws/sys/new/user', postData_).then(function(response) {
					let res = response.data;
					if(0 === res.meta.code) {
						if(_this.$i18n.locale=='zh'){
							_this.$Message.success('修改成员账号成功');
						}else if(_this.$i18n.locale=='en'){
							_this.$Message.success('Modify member account successfully');
						}else if(_this.$i18n.locale=='it'){
							_this.$Message.success("Modifica l'account membro con successo");
						}
						
						_this.accountModalCancel();
						_this.init();
					} else {
						let message_ = res.meta.message;
						if(_this.$i18n.locale=='zh'){
							_this.$Message.warning('修改成员账号失败' + message_);
						}else if(_this.$i18n.locale=='en'){
							_this.$Message.warning('Failed to modify member account' + message_);
						}else if(_this.$i18n.locale=='it'){
							_this.$Message.warning("Impossibile modificare l'account membro" + message_);
						}
						
					}
				});
			},			
			/**
			 * 账号新增的弹框取消操作
			 */
			accountModalCancel() {
				this.$refs['accountForm'].resetFields();
				this.accountModal.show = false;
			},
			/**
			 * 表格选择变更事件
			 */
			tableSelected(selection_) {
				this.table.selection = selection_;
			},
			/**
			 * 批量删除选中的账号
			 */
			batchDelAccounts() {
				if(this.$i18n.locale=='zh'){
					this.$confirm({
						content: '你确认删除选中的账号数据吗?',
						onOk: function() {
							alert('确认');
						}
					});
				}else if(this.$i18n.locale=='en'){
					this.$confirm({
						content: 'Delete the selected account data?',
						onOk: function() {
							alert('confirm');
						}
					});
				}else if(this.$i18n.locale=='it'){
					this.$confirm({
						content: "Eliminare i dati dell'account selezionato?",
						onOk: function() {
							alert('confermare');
						}
					});
				}
				
			},
			/**
			 * 删除提示
			 */
			delConfirm(row_) {
				const _this = this;
				if(_this.$i18n.locale=='zh'){
					this.$confirm({
						title: '操作提示',
						width: 300,
						content: '你确认删除本行记录吗?',
						onOk: function() {
							_this.delTableRow(row_);
						}
					});
				}else if(_this.$i18n.locale=='en'){
					this.$confirm({
						title: 'Alert',
						width: 300,
						content: 'Delete your bank records?',
						onOk: function() {
							_this.delTableRow(row_);
						}
					});
				}else if(_this.$i18n.locale=='it'){
					this.$confirm({
						title: 'Operazione richiesta',
						width: 300,
						content: 'Sei sicuro di cancellare i tuoi dati bancari?',
						onOk: function() {
							_this.delTableRow(row_);
						}
					});
				}
								
			},
			/**
			 * 删除表格行
			 */
		    delTableRow(rowItem_) { //删除行
		      let rId = rowItem_.id;
		      let rsv_ = rowItem_.rsv_;
		      const _this = this;
		      this.axios.delete('/ws/sys/new/user/' + rId + '/' + rsv_).then(function(response) {
		      		let res = response.data;
					if(0 === res.meta.code) {
						if(_this.$i18n.locale=='zh'){
							_this.$Message.success('删除记录成功');
						}else if(_this.$i18n.locale=='en'){
							_this.$Message.success('Delete record successfully');
						}else if(_this.$i18n.locale=='it'){
							_this.$Message.success('Elimina il record con successo');
						}
						
						_this.init();
					} else {
						let message_ = res.meta.message;
						if(_this.$i18n.locale=='zh'){
							_this.$Message.warning('删除资源记录项失败:' + message_);
						}else if(_this.$i18n.locale=='en'){
							_this.$Message.warning('Deleting resource record entries failed:' + message_);
						}else if(_this.$i18n.locale=='it'){
							_this.$Message.warning("L'eliminazione delle voci del record delle risorse non è riuscita:" + message_);
						}
						
					}
		      });
		    },
		    /**
		     * 锁定账号(提示)
		     */
		    confirmLockAccount(row_) {
				const _this = this;
				if(_this.$i18n.locale=='zh'){
					this.$confirm({
						title: '操作提示',
						width: 300,
						content: '你确认锁定此帐号吗?',
						onOk: function() {
							_this.lockAccount(row_);
						}
					});			
				}else if(_this.$i18n.locale=='en'){
					this.$confirm({
						title: 'Alert',
						width: 300,
						content: 'Lock this account?',
						onOk: function() {
							_this.lockAccount(row_);
						}
					});	
				}else if(_this.$i18n.locale=='it'){
					this.$confirm({
						title: 'Operazione richiesta',
						width: 300,
						content: 'Sei sicuro di bloccare questo account?',
						onOk: function() {
							_this.lockAccount(row_);
						}
					});		
				}
				    	
		    },
		    /**
		     * 锁定账号
		     */
		    lockAccount(row_) {
				const _this = this;
				let rId = row_.id;
		      	let rsv_ = row_.rsv_;
				this.axios.put('/ws/sys/user/lock/' + rId + '/' + rsv_).then(function(response) {
					let res = response.data;
					if(0 === res.meta.code) {
						if(_this.$i18n.locale=='zh'){
							_this.$Message.success('锁定账号成功');
						}else if(_this.$i18n.locale=='en'){
							_this.$Message.success('Lock account successfully');
						}else if(_this.$i18n.locale=='it'){
							_this.$Message.success("Blocca l'account con successo");
						}
						
						_this.init();
					} else {
						let message_ = res.meta.message;
						if(_this.$i18n.locale=='zh'){
							_this.$Message.warning('锁定账号失败:' + message_);
						}else if(_this.$i18n.locale=='en'){
							_this.$Message.warning('Lock account failed:' + message_);
						}else if(_this.$i18n.locale=='it'){
							_this.$Message.warning('Blocca account non riuscito:' + message_);
						}
						
					}
				});		    	
		    },
		    confirmUnLockAccount(row_) {
				const _this = this;
				if(_this.$i18n.locale=='zh'){
					this.$confirm({
						title: '操作提示',
						width: 300,
						content: '你确认解锁此帐号吗?',
						onOk: function() {
							_this.unLockAccount(row_);
						}
					});	
				}else if(_this.$i18n.locale=='en'){
					this.$confirm({
						title: 'Alert',
						width: 300,
						content: 'Unlock this account?',
						onOk: function() {
							_this.unLockAccount(row_);
						}
					});	
				}else if(_this.$i18n.locale=='it'){
					this.$confirm({
						title: 'Operazione richiesta',
						width: 300,
						content: 'Sei sicuro di sbloccare questo account?',
						onOk: function() {
							_this.unLockAccount(row_);
						}
					});	
				}

						    	
		    },
		    /**
		     * 解锁账号
		     */
		    unLockAccount(row_) {
				const _this = this;
				let rId = row_.id;
		      	let rsv_ = row_.rsv_;
				this.axios.put('/ws/sys/user/unlock/' + rId + '/' + rsv_).then(function(response) {
					let res = response.data;
					if(0 === res.meta.code) {
						if(_this.$i18n.locale=='zh'){
							_this.$Message.success('解锁账号成功');
						}else if(_this.$i18n.locale=='en'){
							_this.$Message.success('Unlock the account successfully');
						}else if(_this.$i18n.locale=='it'){
							_this.$Message.success("Sblocca l'account con successo");
						}
						
						_this.init();
					} else {
						let message_ = res.meta.message;
						if(_this.$i18n.locale=='zh'){
							_this.$Message.warning('解锁账号失败:' + message_);
						}else if(_this.$i18n.locale=='en'){
							_this.$Message.warning('Unlocking account failed:' + message_);
						}else if(_this.$i18n.locale=='it'){
							_this.$Message.warning('Account di sblocco non riuscito:' + message_);
						}
						
					}
				});				    	
		    },
		    /**
		     * 确认重置账号密码
		     */
		    confirmResetAccountPwd() {
				const _this = this;
				this.$confirm({
        			title: '操作提示',
        			width: 300,
        			content: '你确认重置选中的账号密码为(wsplus@123)吗?',
        			onOk: function() {
        				_this.resetAccountPwd();
        			}
        		});			    	
		    },
		    /**
		     * 重置密码
		     */
		    resetAccountPwd() {
		    	const _this = this;
		    	let selectRows_ = this.table.selection;
		    	let selectedList = [];
		    	for(let i = 0; i < selectRows_.length; i++) {
		    		let row_ = selectRows_[i];
		    		selectedList.push({
		    			id: row_.id
		    		});
		    	}
		    	let postData_ = {
		    		selectedList: selectedList
		    	};
				this.axios.put('/ws/sys/user/batch/resetpwd', postData_).then(function(response) {
					let res = response.data;
					if(0 === res.meta.code) {
						_this.$Message.success('重置选中账号密码成功');
						_this.init();
					} else {
						let message_ = res.meta.message;
						_this.$Message.warning('重置选中账号密码失败:' + message_);
					}
				});		    	
		    }
		}
	}
</script>

<style scoped>
	.ws-form-select {
		width: 162px;
	}
</style>